home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJLSR106.ARJ / EH.CC < prev    next >
C/C++ Source or Header  |  1992-03-24  |  757b  |  44 lines

  1. /* Library code for programs which use -fhandle-exceptions.
  2.    Note: do *not* compile this with -fhandle-exceptions.  */
  3.  
  4.  
  5. #ifdef __GNUG__
  6. #pragma implementation
  7. #endif
  8. #include <setjmp.h>
  9. #include <stream.h>
  10.  
  11. struct
  12. ExceptionHandler
  13. {
  14.   ExceptionHandler *prev;
  15.   jmp_buf handler;
  16.   void *name;
  17.   void *parameters;
  18.   ExceptionHandler ();
  19.   ~ExceptionHandler ();
  20. } EHS, *exceptionHandlerStack = &EHS;
  21.  
  22. ExceptionHandler::ExceptionHandler ()
  23. {
  24.   if (this == &EHS)
  25.     {
  26.       if (setjmp (EHS.handler))
  27.     {
  28.       cerr << ("unhandled exception, aborting...\n");
  29.       abort ();
  30.     }
  31.     }
  32.   else
  33.     {
  34.       this->prev = exceptionHandlerStack;
  35.       exceptionHandlerStack = this;
  36.     }
  37. }
  38.  
  39. ExceptionHandler::~ExceptionHandler ()
  40. {
  41.   exceptionHandlerStack = this->prev;
  42. }
  43.  
  44.